import {Inject, Controller, Get, Post, Body} from '@midwayjs/core';
import { Context } from '@midwayjs/koa';
import { UserService } from '../service/user.service';
import {UserSaveDto} from "../dto/UserSaveDto";

@Controller('/user')
export class APIController {
  @Inject()
  ctx: Context;

  @Inject()
  userService: UserService;

  @Get('/getUserList')
  async getUserList() {
    const user = await this.userService.getUserList();
    return { success: true, message: 'OK', data: user };
  }

  @Post('/saveUser')
  async saveUser(@Body() options: UserSaveDto) {
    const user = await this.userService.saveUser(options);
    return { success: true, message: 'OK', data: user };
  }

}
